import request from '@/utils/request'

// 查询合同列表
export function listBusiness(query) {
  return request({
    url: '/business/list',
    method: 'get',
    params: query
  })
}


// 查询合同列表(多选)
export function listBusinessType(query) {
  return request({
    url: '/business/listType',
    method: 'get',
    params: query
  })
}

// 根据合同id查询合同详情
export function getContractById(query) {
  return request({
    url: '/business/'+query,
    method: 'get'
  })
}

// 新增合同
export function addContract(data) {
  return request({
    url: '/business/add/',
    method: 'post',
    data: data
  })
}

// 获取外部对象
export function VCtmsClientLabel(query) {
  return request({
    url: '/business/VCtmsClientLabel/',
    method: 'get'
  })
}

// 获取码头
export function getCompanyCode(query) {
  return request({
    url: '/business/getCompanyCode',
    method: 'get'
  })
}

// 获取业务类型
export function SprojectLabel(query) {
  return request({
    url: '/business/SprojectLabel/',
    method: 'get'
  })
}

// 修改合同
export function editContract(data) {
  return request({
    url: '/business/edit/',
    method: 'put',
    data: data
  })
}

// 校验外部对象是否一致
export function contrastObj(query) {
  return request({
    url: '/business/contrastObj',
    method: 'get',
    params: query
  })
}

// 修改外部对象
export function editObjOut(data) {
  return request({
    url: '/business/editObjOut',
    method: 'put',
    data: data
  })
}


// oneKeyAddOutObjectsBatch 一键添加外部对象
export function oneKeyAddOutObjectsBatch(data) {
  return request({
    url: '/conobj/oneKeyAddOutObjectsBatch',
    method: 'post',
    data: data
  })
}

// 冻结解冻合同
export function frozenContractById(conId) {
  return request({
    url: '/business/frozen/'+conId,
    method: 'post'
  })
}

// 作废合同
export function nullifyContractById(conId) {
  return request({
    url: '/business/nullify/'+conId,
    method: 'post'
  })
}

// 删除合同
export function deleteContractById(conId) {
  return request({
    url: '/business/delete/'+conId,
    method: 'post'
  })
}

// 恢复作废合同
export function restoreNullifyContractById(conId) {
  return request({
    url: '/business/restoreNullify/'+conId,
    method: 'post'
  })
}

//获取合同文件信息
export function getConFile(query) {
  return request({
    url: '/business/getConFile',
    method: 'get',
    params: query
  })
}

//获取合同文件列表
export function listConFile(query){
  return request({
    url: '/confile/list',
    method: 'get',
    params: query
  })
}

//获取合同文件列表
export function deleteConFileByFileId(query){
  return request({
    url: '/confile/delete/'+query,
    method: 'post',
  })
}

//获取合同id获取文件
export function getConFileByFileId(query){
  return request({
    url: '/confile/'+query,
    method: 'get',
  })
}


//获取合同日志列表
export function listConOperLog(conId){
  return request({
    url: '/conLog/list/'+conId,
    method: 'get'
  })
}

//复制合同
export function copyConBusiness(conId){
  return request({
    url: '/business/copyContractById/' + conId,
    method: 'post',
  })
}


// 发送get请求到checkContractByConCodeAndOrderId，根据orderId和conCode查询合同匹配情况
export function checkContractByConCodeAndOrderId(query) {
  return request({
    url: '/business/checkContractByConCodeAndOrderId',
    method: 'get',
    params: query
  })
}
// 发送post请求到/checkContractByParam，查询合同匹配情况
export function checkContractByParam(data) {
  return request({
    url: '/business/checkContractByParam',
    method: 'post',
    data: data
  })
}

export function importLastApprover(query) {
  return request({
    url: '/business/importLastApprover',
    method: 'get',
    params: query
  })
}

export function importLastApproverCon(query) {
  return request({
    url: '/business/importLastApproverCon',
    method: 'get',
    params: query
  })
}

export function getConDict(data){
  return request({
    url: '/business/getConDict',
    method: 'post',
    data: data
  })
}

/**
 * 根据statementId查询该对账单下费项所绑定计费合同的conId
 * @param data
 * @returns {AxiosPromise}
 */
export function getConIdByStatementId(data){
  return request({
    url: '/business/getConIdByStatementId',
    method: 'post',
    data: data
  })
}
